package com.goldsprite.infinityworld.assets;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.goldsprite.gdxcore.utils.FontUtils;

public class GlobalAssets {
	//单例
	private static GlobalAssets instance;

	//静态路径
	public static String skinPath = "ui_skins/shade/skin/uiskin.json";
//	public static String cellTexturesPath = "cellTextures.png";
//	public static String avatarPath = "shikeik_avatar.png";
//	public static String logoPath = "greetings.png";

	//预设常量
	public static final int editorFontSize = 35;
	public static final float editorFontScl = 0.5f;
	public static final float editorSplitHandleSize = 12;
	public static final int editorWindowResizeBorderSize = 20;

	//实例资源
	public Texture cellTextures;
	public Texture avatarTex;

	public Skin defaultSkin;
	public BitmapFont font;

	public Skin editorSkin;
	public BitmapFont editorFont, editorFontGray;


	public GlobalAssets() {
		instance = this;

		//材质
//		cellTextures = new Texture(cellTexturesPath);
//		avatarTex = new Texture(avatarPath);

		//默认主题
		defaultSkin = new Skin(Gdx.files.internal(skinPath));
		font = FontUtils.generate();

		//编辑器主题
		{
			editorFont = FontUtils.generate(editorFontSize);
			editorFont.getData().setScale(editorFontScl);
			editorFontGray = FontUtils.generate(editorFontSize);
			editorFontGray.getData().setScale(editorFontScl);
			editorFontGray.setColor(Color.GRAY);
			editorSkin = new Skin(Gdx.files.internal(GlobalAssets.skinPath));

			Label.LabelStyle labelStyle = editorSkin.get(Label.LabelStyle.class);
			labelStyle.font = editorSkin.getFont("font-button");

			TextButton.TextButtonStyle textButtonStyle = editorSkin.get(TextButton.TextButtonStyle.class);
			textButtonStyle.font = editorSkin.getFont("font-button");

			TextField.TextFieldStyle textFieldStyle = editorSkin.get(TextField.TextFieldStyle.class);
			textFieldStyle.font = editorSkin.getFont("font-button");
			textFieldStyle.messageFont = editorFontGray;

			SplitPane.SplitPaneStyle splitPaneStyle = editorSkin.get("default-vertical", SplitPane.SplitPaneStyle.class);
			Drawable handle = splitPaneStyle.handle;
			handle.setMinHeight(editorSplitHandleSize);
			SplitPane.SplitPaneStyle splitPaneStyleHori = editorSkin.get("default-horizontal", SplitPane.SplitPaneStyle.class);
			Drawable handleHori = splitPaneStyleHori.handle;
			handleHori.setMinWidth(editorSplitHandleSize);

			Touchpad.TouchpadStyle touchpadStyle = editorSkin.get(Touchpad.TouchpadStyle.class);
			Drawable knob = touchpadStyle.knob;
			knob.setMinWidth(40);
			knob.setMinHeight(40);
		}
	}

	public static GlobalAssets getInstance() {
		return instance;
	}
}

